﻿Imports System.Data.OleDb

Public Class AddAnswers
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click

        Dim p1 As New OleDbParameter("@f1", Request.QueryString("ID"))
        Dim p2 As New OleDbParameter("@f2", txtTitle.Text)
        Dim p3 As New OleDbParameter("@f3", txtDesc.Text)
        Dim p4 As New OleDbParameter("@f4", User.Identity.Name)
        Dim p5 As New OleDbParameter("@f5", Format(Date.Now(), "dd/MM/yyyy hh:mm:ss tt"))
        Dim sql As String = "insert into CricQuestionAnswers(CricQuestionID,Title,UserAnswers,CreatedBy,AnsweredDate) values (@f1,@f2,@f3,@f4,@f5)"
        DataAccessLayer.ExecuteNonQuery(sql, p1, p2, p3, p4, p5)

        Dim sql2 As String = "Update userprofile set QuariesAnswered= QuariesAnswered+1 where username =@f4 "
        DataAccessLayer.ExecuteNonQuery(sql2, p4)

        Response.Redirect("~/CricAnswers.aspx?ID=" & Request.QueryString("ID"))
    End Sub
End Class